package listener;

import com.alibaba.excel.context.AnalysisContext;

import com.alibaba.excel.metadata.data.CellData;
import com.alibaba.excel.metadata.data.ReadCellData;
import pojo.Student;

import java.util.Map;

public class ReadListener implements com.alibaba.excel.read.listener.ReadListener<Student> {
    @Override
    public void onException(Exception e, AnalysisContext analysisContext) throws Exception {
        //出现异常执行
    }

    @Override
    public void invokeHead(Map<Integer, ReadCellData<?>> headMap, AnalysisContext context) {
        //读第一行时执行
        System.out.println("读到表头" + headMap);
    }

    @Override
    public void invoke(Student student, AnalysisContext analysisContext) {
        //每读一行内容执行一次,不包含第一行表头

        //读到的内容
        System.out.println("student = " + student);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
        //读完后执行一次
        System.out.println("读完了 ");
    }

}
